#pragma once
#include "tinyxml.h"
#include <boost/lexical_cast.hpp>
#include <map>
#include <fstream>
using namespace std;
class FTOA:
	public std::unary_function<double, string>
{
public:
	FTOA() {};
	~FTOA() {};
	const string operator()(const double& rhs)
	{
		using boost::lexical_cast;
		return (lexical_cast<string> (rhs));
	}
		 
};
// converting a vector of doubles to a string with ',' as the delimeter
const string number2string(const vector<double>& in);
// open a file given name
ofstream& open_file(ofstream& file, const string& filename);
// output a a vector of doubles to a file
//bool numbers2file(ofstream& file, const string& comment, const vector<double>& iv);
class OutputData
{
public:
	typedef std::map<std::string,std::string> MessageMap;
	// write runoff during calibration to the file
	bool RunoffCalibration(const vector<double>& vr);
	// write runoff during validation to the file
	bool RunoffValidation(const vector<double>& vr);
	// write runoff during simulation to the file
	bool RunoffSimulation(const vector<double>& vr);
	// write the NCUC model parameters to the xml file
	bool ModelParameters(const vector<double>& vr);
	// write CE value of the calibration to the xml file
	bool CECalibration(const double& ce);
	// write CE value of the validation to the xml file
	bool CEValidation(const double& ce);
	// write CE value of the simulation to the xml file
	bool CESimulation(const double& ce);
	// read the base file to be the basis
	bool BaseFile(const string& infile);
	// save the XML file
	bool SaveFile(const string& name);
	OutputData();
	OutputData(const string& infile);
	~OutputData(void);
private:
	void dump(const string& name, const vector<double>& vr);
	// master document
	TiXmlDocument m_doc;
	TiXmlElement* m_root; // root element for the output
	MessageMap m_map; // Runoff during Calibration
};
